package com.glorystone.ins.service.impl;

import com.glorystone.ins.dao.CapitalRecordMapper;
import com.glorystone.ins.domain.CapitalRecord;
import com.glorystone.ins.domain.Order;
import com.glorystone.ins.service.CapitalRecordService;

import com.glorystone.ins.vo.OrderQueryConditionVo;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public @Slf4j class CapitalRecordServiceImpl implements CapitalRecordService{
	@Autowired
	private CapitalRecordMapper capitalRecordMapper; 
	@Override
	public List<CapitalRecord> selectOrderCapitalRecord(OrderQueryConditionVo order) {
		log.debug("根据订单ID查询资金流水信息开始");
		List<CapitalRecord> recordList = null;
		try {
			if(order!=null){
				log.debug("订单编号ID是"+order.getTid());
				recordList = capitalRecordMapper.selectRecordByOrderId(order.getTid());
			}else{
				log.debug("order为空，无法获取查询条件");
			}
		} catch (Exception e) {
			log.error("根据订单ID查询资金流水信息异常",e);
		}
		log.debug("根据订单Id查询资金流水信息结束");
		return recordList;
	}

	@Override
	public Integer insertCaptialRecord(List<CapitalRecord> capitalRecords) {
		Integer num = capitalRecordMapper.insertList(capitalRecords);
		return num;
	}

	@Override
	public CapitalRecord selectCapitalRecord(Long orderId, Integer opponentType, Integer tradeType) {
		log.debug("根据订单ID查询资金流水信息开始");
		CapitalRecord record = null;
		try {
			record = capitalRecordMapper.selectCapitalRecord(orderId,opponentType,tradeType);
		} catch (Exception e) {
			log.error("根据订单ID查询资金流水信息异常",e);
		}
		log.debug("根据订单Id查询资金流水信息结束");
		return record;
	}

}
